<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Float - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-Float-label-What-27s+Here">What’s Here</a>
    <li><a href="#class-Float-label-Querying">Querying</a>
    <li><a href="#class-Float-label-Comparing">Comparing</a>
    <li><a href="#class-Float-label-Converting">Converting</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Numeric.html">Numeric</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-25">#%</a>
    <li ><a href="#method-i-2A">#*</a>
    <li ><a href="#method-i-2A-2A">#**</a>
    <li ><a href="#method-i-2B">#+</a>
    <li ><a href="#method-i-2D">#-</a>
    <li ><a href="#method-i-2D-40">#-@</a>
    <li ><a href="#method-i-2F">#/</a>
    <li ><a href="#method-i-3C">#&lt;</a>
    <li ><a href="#method-i-3C-3D">#&lt;=</a>
    <li ><a href="#method-i-3C-3D-3E">#&lt;=&gt;</a>
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-3D-3D-3D">#===</a>
    <li ><a href="#method-i-3E">#&gt;</a>
    <li ><a href="#method-i-3E-3D">#&gt;=</a>
    <li ><a href="#method-i-abs">#abs</a>
    <li ><a href="#method-i-angle">#angle</a>
    <li ><a href="#method-i-arg">#arg</a>
    <li ><a href="#method-i-ceil">#ceil</a>
    <li ><a href="#method-i-coerce">#coerce</a>
    <li ><a href="#method-i-denominator">#denominator</a>
    <li ><a href="#method-i-divmod">#divmod</a>
    <li ><a href="#method-i-eql-3F">#eql?</a>
    <li ><a href="#method-i-fdiv">#fdiv</a>
    <li ><a href="#method-i-finite-3F">#finite?</a>
    <li ><a href="#method-i-floor">#floor</a>
    <li ><a href="#method-i-hash">#hash</a>
    <li ><a href="#method-i-infinite-3F">#infinite?</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-magnitude">#magnitude</a>
    <li ><a href="#method-i-modulo">#modulo</a>
    <li ><a href="#method-i-nan-3F">#nan?</a>
    <li ><a href="#method-i-negative-3F">#negative?</a>
    <li ><a href="#method-i-next_float">#next_float</a>
    <li ><a href="#method-i-numerator">#numerator</a>
    <li ><a href="#method-i-phase">#phase</a>
    <li ><a href="#method-i-positive-3F">#positive?</a>
    <li ><a href="#method-i-prev_float">#prev_float</a>
    <li ><a href="#method-i-quo">#quo</a>
    <li ><a href="#method-i-rationalize">#rationalize</a>
    <li ><a href="#method-i-round">#round</a>
    <li ><a href="#method-i-to_f">#to_f</a>
    <li ><a href="#method-i-to_i">#to_i</a>
    <li ><a href="#method-i-to_int">#to_int</a>
    <li ><a href="#method-i-to_r">#to_r</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-truncate">#truncate</a>
    <li ><a href="#method-i-zero-3F">#zero?</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Float">
    <h1 id="class-Float" class="class">
      class Float
    </h1>

    <section class="description">
    
<p>A Float object represents a sometimes-inexact real number using the native architecture’s double-precision floating point representation.</p>

<p>Floating point has a different arithmetic and is an inexact number. So you should know its esoteric system. See following:</p>
<ul><li>
<p><a href="https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html">docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html</a></p>
</li><li>
<p><a href="https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rubys-floats-imprecise">github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rubys-floats-imprecise</a></p>
</li><li>
<p><a href="https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems">en.wikipedia.org/wiki/Floating_point#Accuracy_problems</a></p>
</li></ul>

<p>You can create a Float object explicitly with:</p>
<ul><li>
<p>A <a href="syntax/literals_rdoc.html#label-Float+Literals">floating-point literal</a>.</p>
</li></ul>

<p>You can convert certain objects to Floats with:</p>
<ul><li>
<p>Method <a href="Kernel.html#method-i-Float"><code>Float</code></a>.</p>
</li></ul>

<h2 id="class-Float-label-What-27s+Here">What’s Here<span><a href="#class-Float-label-What-27s+Here">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>First, what’s elsewhere. Class Float:</p>
<ul><li>
<p>Inherits from <a href="Numeric.html#class-Numeric-label-What-27s+Here">class Numeric</a>.</p>
</li></ul>

<p>Here, class Float provides methods for:</p>
<ul><li>
<p><a href="Float.html#class-Float-label-Querying">Querying</a></p>
</li><li>
<p><a href="Float.html#class-Float-label-Comparing">Comparing</a></p>
</li><li>
<p><a href="Float.html#class-Float-label-Converting">Converting</a></p>
</li></ul>

<h3 id="class-Float-label-Querying">Querying<span><a href="#class-Float-label-Querying">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Float.html#method-i-finite-3F"><code>finite?</code></a>: Returns whether <code>self</code> is finite.</p>
</li><li>
<p><a href="Float.html#method-i-hash"><code>hash</code></a>: Returns the integer hash code for <code>self</code>.</p>
</li><li>
<p><a href="Float.html#method-i-infinite-3F"><code>infinite?</code></a>: Returns whether <code>self</code> is infinite.</p>
</li><li>
<p><a href="Float.html#method-i-nan-3F"><code>nan?</code></a>: Returns whether <code>self</code> is a NaN (not-a-number).</p>
</li></ul>

<h3 id="class-Float-label-Comparing">Comparing<span><a href="#class-Float-label-Comparing">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p>#&lt;: Returns whether <code>self</code> is less than the given value.</p>
</li><li>
<p>#&lt;=: Returns whether <code>self</code> is less than or equal to the given value.</p>
</li><li>
<p>#&lt;=&gt;: Returns a number indicating whether <code>self</code> is less than, equal to, or greater than the given value.</p>
</li><li>
<p><a href="Float.html#method-i-3D-3D"><code>==</code></a> (aliased as <a href="Float.html#method-i-3D-3D-3D"><code>===</code></a> and <a href="Float.html#method-i-eql-3F"><code>eql?</code></a>): Returns whether <code>self</code> is equal to the given value.</p>
</li><li>
<p>#&gt;: Returns whether <code>self</code> is greater than the given value.</p>
</li><li>
<p>#&gt;=: Returns whether <code>self</code> is greater than or equal to the given value.</p>
</li></ul>

<h3 id="class-Float-label-Converting">Converting<span><a href="#class-Float-label-Converting">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="Float.html#method-i-25"><code>%</code></a> (aliased as <a href="Float.html#method-i-modulo"><code>modulo</code></a>): Returns <code>self</code> modulo the given value.</p>
</li><li>
<p><a href="Float.html#method-i-2A"><code>*</code></a>: Returns the product of <code>self</code> and the given value.</p>
</li><li>
<p><a href="Float.html#method-i-2A"><code>*</code></a>*: Returns the value of <code>self</code> raised to the power of the given value.</p>
</li><li>
<p><a href="Float.html#method-i-2B"><code>+</code></a>: Returns the sum of <code>self</code> and the given value.</p>
</li><li>
<p><a href="Float.html#method-i-2D"><code>-</code></a>: Returns the difference of <code>self</code> and the given value.</p>
</li><li>
<p>#/: Returns the quotient of <code>self</code> and the given value.</p>
</li><li>
<p><a href="Float.html#method-i-ceil"><code>ceil</code></a>: Returns the smallest number greater than or equal to <code>self</code>.</p>
</li><li>
<p><a href="Float.html#method-i-coerce"><code>coerce</code></a>: Returns a 2-element array containing the given value converted to a Float and <code>self</code></p>
</li><li>
<p><a href="Float.html#method-i-divmod"><code>divmod</code></a>: Returns a 2-element array containing the quotient and remainder results of dividing <code>self</code> by the given value.</p>
</li><li>
<p><a href="Float.html#method-i-fdiv"><code>fdiv</code></a>: Returns the Float result of dividing <code>self</code> by the given value.</p>
</li><li>
<p><a href="Float.html#method-i-floor"><code>floor</code></a>: Returns the greatest number smaller than or equal to <code>self</code>.</p>
</li><li>
<p><a href="Float.html#method-i-next_float"><code>next_float</code></a>: Returns the next-larger representable Float.</p>
</li><li>
<p><a href="Float.html#method-i-prev_float"><code>prev_float</code></a>: Returns the next-smaller representable Float.</p>
</li><li>
<p><a href="Float.html#method-i-quo"><code>quo</code></a>: Returns the quotient from dividing <code>self</code> by the given value.</p>
</li><li>
<p><a href="Float.html#method-i-round"><code>round</code></a>: Returns <code>self</code> rounded to the nearest value, to a given precision.</p>
</li><li>
<p><a href="Float.html#method-i-to_i"><code>to_i</code></a> (aliased as <a href="Float.html#method-i-to_int"><code>to_int</code></a>): Returns <code>self</code> truncated to an <a href="Integer.html"><code>Integer</code></a>.</p>
</li><li>
<p><a href="Float.html#method-i-to_s"><code>to_s</code></a> (aliased as <a href="Float.html#method-i-inspect"><code>inspect</code></a>): Returns a string containing the place-value representation of <code>self</code> in the given radix.</p>
</li><li>
<p><a href="Float.html#method-i-truncate"><code>truncate</code></a>: Returns <code>self</code> truncated to a given precision.</p>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="DIG">DIG
          <dd><p>The minimum number of significant decimal digits in a double-precision floating point.</p>

<p>Usually defaults to 15.</p>
          <dt id="EPSILON">EPSILON
          <dd><p>The difference between 1 and the smallest double-precision floating point number greater than 1.</p>

<p>Usually defaults to 2.2204460492503131e-16.</p>
          <dt id="INFINITY">INFINITY
          <dd><p>An expression representing positive infinity.</p>
          <dt id="MANT_DIG">MANT_DIG
          <dd><p>The number of base digits for the <code>double</code> data type.</p>

<p>Usually defaults to 53.</p>
          <dt id="MAX">MAX
          <dd><p>The largest possible integer in a double-precision floating point number.</p>

<p>Usually defaults to 1.7976931348623157e+308.</p>
          <dt id="MAX_10_EXP">MAX_10_EXP
          <dd><p>The largest positive exponent in a double-precision floating point where 10 raised to this power minus 1.</p>

<p>Usually defaults to 308.</p>
          <dt id="MAX_EXP">MAX_EXP
          <dd><p>The largest possible exponent value in a double-precision floating point.</p>

<p>Usually defaults to 1024.</p>
          <dt id="MIN">MIN
          <dd><p>The smallest positive normalized number in a double-precision floating point.</p>

<p>Usually defaults to 2.2250738585072014e-308.</p>

<p>If the platform supports denormalized numbers, there are numbers between zero and <a href="Float.html#MIN"><code>Float::MIN</code></a>. 0.0.next_float returns the smallest positive floating point number including denormalized numbers.</p>
          <dt id="MIN_10_EXP">MIN_10_EXP
          <dd><p>The smallest negative exponent in a double-precision floating point where 10 raised to this power minus 1.</p>

<p>Usually defaults to -307.</p>
          <dt id="MIN_EXP">MIN_EXP
          <dd><p>The smallest possible exponent value in a double-precision floating point.</p>

<p>Usually defaults to -1021.</p>
          <dt id="NAN">NAN
          <dd><p>An expression representing a value which is “not a number”.</p>
          <dt id="RADIX">RADIX
          <dd><p>The base of the floating point, or number of unique digits used to represent the number.</p>

<p>Usually defaults to 2 on most systems, which would represent a base-10 decimal.</p>
        </dl>
        </section>



                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-25" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self % other &rarr; float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code> modulo <code>other</code> as a float.</p>

<p>For float <code>f</code> and real number <code>r</code>, these expressions are equivalent:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">r</span>
<span class="ruby-identifier">f</span><span class="ruby-operator">-</span><span class="ruby-identifier">r</span><span class="ruby-operator">*</span>(<span class="ruby-identifier">f</span><span class="ruby-operator">/</span><span class="ruby-identifier">r</span>).<span class="ruby-identifier">floor</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-identifier">r</span>)[<span class="ruby-value">1</span>]
</pre>

<p>See <a href="Numeric.html#method-i-divmod"><code>Numeric#divmod</code></a>.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; 0.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">3</span>              <span class="ruby-comment"># =&gt; 1.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">4</span>              <span class="ruby-comment"># =&gt; 2.0</span>

<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">-2</span>             <span class="ruby-comment"># =&gt; 0.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">-3</span>             <span class="ruby-comment"># =&gt; -2.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">-4</span>             <span class="ruby-comment"># =&gt; -2.0</span>

<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">4.0</span>            <span class="ruby-comment"># =&gt; 2.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">4</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 2.0</span>
</pre>

                              <div class="method-source-code" id="25-source">
            <pre>static VALUE
flo_mod(VALUE x, VALUE y)
{
    double fy;

    if (FIXNUM_P(y)) {
        fy = (double)FIX2LONG(y);
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        fy = rb_big2dbl(y);
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        fy = RFLOAT_VALUE(y);
    }
    else {
        return rb_num_coerce_bin(x, y, &#39;%&#39;);
    }
    return DBL2NUM(ruby_float_mod(RFLOAT_VALUE(x), fy));
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Float.html#method-i-modulo">modulo</a>
                            </div>

                          </div>

                  <div id="method-i-2A" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self * other &rarr; numeric
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a new Float which is the product of <code>self</code> and <code>other</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">*</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; 6.28</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">*</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; 6.28</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">*</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">1</span>, <span class="ruby-value">2</span>) <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">*</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; (6.28+0.0i)</span>
</pre>

                              <div class="method-source-code" id="2A-source">
            <pre>VALUE
rb_float_mul(VALUE x, VALUE y)
{
    if (FIXNUM_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y));
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y));
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y));
    }
    else {
        return rb_num_coerce_bin(x, y, &#39;*&#39;);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2A-2A" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self ** other &rarr; numeric
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Raises <code>self</code> to the power of <code>other</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">**</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; 9.8596</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">**</span> <span class="ruby-value">-2</span>             <span class="ruby-comment"># =&gt; 0.1014239928597509</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">**</span> <span class="ruby-value">2.1</span>            <span class="ruby-comment"># =&gt; 11.054834900588839</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">**</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 9.8596</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">**</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; (9.8596+0i)</span>
</pre>

                              <div class="method-source-code" id="2A-2A-source">
            <pre>VALUE
rb_float_pow(VALUE x, VALUE y)
{
    double dx, dy;
    if (y == INT2FIX(2)) {
        dx = RFLOAT_VALUE(x);
        return DBL2NUM(dx * dx);
    }
    else if (FIXNUM_P(y)) {
        dx = RFLOAT_VALUE(x);
        dy = (double)FIX2LONG(y);
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        dx = RFLOAT_VALUE(x);
        dy = rb_big2dbl(y);
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        dx = RFLOAT_VALUE(x);
        dy = RFLOAT_VALUE(y);
        if (dx &lt; 0 &amp;&amp; dy != round(dy))
            return rb_dbl_complex_new_polar_pi(pow(-dx, dy), dy);
    }
    else {
        return rb_num_coerce_bin(x, y, idPow);
    }
    return DBL2NUM(pow(dx, dy));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2B" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self + other &rarr; numeric
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a new Float which is the sum of <code>self</code> and <code>other</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>                 <span class="ruby-comment"># =&gt; 4.140000000000001</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">+</span> <span class="ruby-value">1.0</span>               <span class="ruby-comment"># =&gt; 4.140000000000001</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">1</span>, <span class="ruby-value">1</span>)    <span class="ruby-comment"># =&gt; 4.140000000000001</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">1</span>, <span class="ruby-value">0</span>)     <span class="ruby-comment"># =&gt; (4.140000000000001+0i)</span>
</pre>

                              <div class="method-source-code" id="2B-source">
            <pre>VALUE
rb_float_plus(VALUE x, VALUE y)
{
    if (FIXNUM_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y));
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y));
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) + RFLOAT_VALUE(y));
    }
    else {
        return rb_num_coerce_bin(x, y, &#39;+&#39;);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self - other &rarr; numeric
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a new Float which is the difference of <code>self</code> and <code>other</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>                 <span class="ruby-comment"># =&gt; 2.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">-</span> <span class="ruby-value">1.0</span>               <span class="ruby-comment"># =&gt; 2.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">-</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">1</span>, <span class="ruby-value">1</span>)    <span class="ruby-comment"># =&gt; 2.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">-</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">1</span>, <span class="ruby-value">0</span>)     <span class="ruby-comment"># =&gt; (2.14+0i)</span>
</pre>

                              <div class="method-source-code" id="2D-source">
            <pre>VALUE
rb_float_minus(VALUE x, VALUE y)
{
    if (FIXNUM_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y));
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y));
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        return DBL2NUM(RFLOAT_VALUE(x) - RFLOAT_VALUE(y));
    }
    else {
        return rb_num_coerce_bin(x, y, &#39;-&#39;);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2D-40" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          -float &rarr; float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code>, negated.</p>

                              <div class="method-source-code" id="2D-40-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/numeric.rb, line 340</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">-@</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;rb_float_uminus(self)&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self / other &rarr; numeric
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a new Float which is the result of dividing <code>self</code> by <code>other</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">/</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">/</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span> <span class="ruby-operator">/</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; (1.57+0.0i)</span>
</pre>

                              <div class="method-source-code" id="2F-source">
            <pre>VALUE
rb_float_div(VALUE x, VALUE y)
{
    double num = RFLOAT_VALUE(x);
    double den;
    double ret;

    if (FIXNUM_P(y)) {
        den = FIX2LONG(y);
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        den = rb_big2dbl(y);
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        den = RFLOAT_VALUE(y);
    }
    else {
        return rb_num_coerce_bin(x, y, &#39;/&#39;);
    }

    ret = double_div_double(num, den);
    return DBL2NUM(ret);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3C" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self &lt; other &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is numerically less than <code>other</code>:</p>

<pre class="ruby"><span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">3</span>              <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">3.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">3</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; false</span>
</pre>

<p><code>Float::NAN &lt; Float::NAN</code> returns an implementation-dependent value.</p>

                              <div class="method-source-code" id="3C-source">
            <pre>static VALUE
flo_lt(VALUE x, VALUE y)
{
    double a, b;

    a = RFLOAT_VALUE(x);
    if (RB_INTEGER_TYPE_P(y)) {
        VALUE rel = rb_integer_float_cmp(y, x);
        if (FIXNUM_P(rel))
            return RBOOL(-FIX2LONG(rel) &lt; 0);
        return Qfalse;
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
        if (isnan(b)) return Qfalse;
#endif
    }
    else {
        return rb_num_coerce_relop(x, y, &#39;&lt;&#39;);
    }
#if MSC_VERSION_BEFORE(1300)
    if (isnan(a)) return Qfalse;
#endif
    return RBOOL(a &lt; b);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3C-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self &lt;= other &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is numerically less than or equal to <code>other</code>:</p>

<pre class="ruby"><span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">3</span>              <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">3.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">3</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">1.0</span>            <span class="ruby-comment"># =&gt; false</span>
</pre>

<p><code>Float::NAN &lt;= Float::NAN</code> returns an implementation-dependent value.</p>

                              <div class="method-source-code" id="3C-3D-source">
            <pre>static VALUE
flo_le(VALUE x, VALUE y)
{
    double a, b;

    a = RFLOAT_VALUE(x);
    if (RB_INTEGER_TYPE_P(y)) {
        VALUE rel = rb_integer_float_cmp(y, x);
        if (FIXNUM_P(rel))
            return RBOOL(-FIX2LONG(rel) &lt;= 0);
        return Qfalse;
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
        if (isnan(b)) return Qfalse;
#endif
    }
    else {
        return rb_num_coerce_relop(x, y, idLE);
    }
#if MSC_VERSION_BEFORE(1300)
    if (isnan(a)) return Qfalse;
#endif
    return RBOOL(a &lt;= b);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3C-3D-3E" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self &lt;=&gt; other &rarr;  -1, 0, +1, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a value that depends on the numeric relation between <code>self</code> and <code>other</code>:</p>
<ul><li>
<p>-1, if <code>self</code> is less than <code>other</code>.</p>
</li><li>
<p>0, if <code>self</code> is equal to <code>other</code>.</p>
</li><li>
<p>1, if <code>self</code> is greater than <code>other</code>.</p>
</li><li>
<p><code>nil</code>, if the two values are incommensurate.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-value">1.9</span>            <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-value">2.1</span>            <span class="ruby-comment"># =&gt; -1</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-string">&#39;foo&#39;</span>          <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>This is the basis for the tests in the <a href="Comparable.html"><code>Comparable</code></a> module.</p>

<p><code>Float::NAN &lt;=&gt; Float::NAN</code> returns an implementation-dependent value.</p>

                              <div class="method-source-code" id="3C-3D-3E-source">
            <pre>static VALUE
flo_cmp(VALUE x, VALUE y)
{
    double a, b;
    VALUE i;

    a = RFLOAT_VALUE(x);
    if (isnan(a)) return Qnil;
    if (RB_INTEGER_TYPE_P(y)) {
        VALUE rel = rb_integer_float_cmp(y, x);
        if (FIXNUM_P(rel))
            return LONG2FIX(-FIX2LONG(rel));
        return rel;
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        b = RFLOAT_VALUE(y);
    }
    else {
        if (isinf(a) &amp;&amp; !UNDEF_P(i = rb_check_funcall(y, rb_intern(&quot;infinite?&quot;), 0, 0))) {
            if (RTEST(i)) {
                int j = rb_cmpint(i, x, y);
                j = (a &gt; 0.0) ? (j &gt; 0 ? 0 : +1) : (j &lt; 0 ? 0 : -1);
                return INT2FIX(j);
            }
            if (a &gt; 0.0) return INT2FIX(1);
            return INT2FIX(-1);
        }
        return rb_num_coerce_cmp(x, y, id_cmp);
    }
    return rb_dbl_cmp(a, b);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self == other &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>other</code> has the same value as <code>self</code>, <code>false</code> otherwise:</p>

<pre class="ruby"><span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p><code>Float::NAN == Float::NAN</code> returns an implementation-dependent value.</p>

<p>Related: <a href="Float.html#method-i-eql-3F"><code>Float#eql?</code></a> (requires <code>other</code> to be a Float).</p>

                              <div class="method-source-code" id="3D-3D-source">
            <pre>VALUE
rb_float_equal(VALUE x, VALUE y)
{
    volatile double a, b;

    if (RB_INTEGER_TYPE_P(y)) {
        return rb_integer_float_eq(y, x);
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
        if (isnan(b)) return Qfalse;
#endif
    }
    else {
        return num_equal(x, y);
    }
    a = RFLOAT_VALUE(x);
#if MSC_VERSION_BEFORE(1300)
    if (isnan(a)) return Qfalse;
#endif
    return RBOOL(a == b);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Float.html#method-i-3D-3D-3D">===</a>
                            </div>

                          </div>

                  <div id="method-i-3D-3D-3D" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">===</span><span
                                class="method-args">(p1)</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>other</code> has the same value as <code>self</code>, <code>false</code> otherwise:</p>

<pre class="ruby"><span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p><code>Float::NAN == Float::NAN</code> returns an implementation-dependent value.</p>

<p>Related: <a href="Float.html#method-i-eql-3F"><code>Float#eql?</code></a> (requires <code>other</code> to be a Float).</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Float.html#method-i-3D-3D">==</a>
                            </div>
                          </div>

                  <div id="method-i-3E" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self &gt; other &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is numerically greater than <code>other</code>:</p>

<pre class="ruby"><span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>              <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">1</span>, <span class="ruby-value">2</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; false</span>
</pre>

<p><code>Float::NAN &gt; Float::NAN</code> returns an implementation-dependent value.</p>

                              <div class="method-source-code" id="3E-source">
            <pre>VALUE
rb_float_gt(VALUE x, VALUE y)
{
    double a, b;

    a = RFLOAT_VALUE(x);
    if (RB_INTEGER_TYPE_P(y)) {
        VALUE rel = rb_integer_float_cmp(y, x);
        if (FIXNUM_P(rel))
            return RBOOL(-FIX2LONG(rel) &gt; 0);
        return Qfalse;
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
        if (isnan(b)) return Qfalse;
#endif
    }
    else {
        return rb_num_coerce_relop(x, y, &#39;&gt;&#39;);
    }
#if MSC_VERSION_BEFORE(1300)
    if (isnan(a)) return Qfalse;
#endif
    return RBOOL(a &gt; b);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3E-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          self &gt;= other &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is numerically greater than or equal to <code>other</code>:</p>

<pre class="ruby"><span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">1</span>              <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">1.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">1</span>, <span class="ruby-value">2</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">2.0</span>            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">2.1</span>            <span class="ruby-comment"># =&gt; false</span>
</pre>

<p><code>Float::NAN &gt;= Float::NAN</code> returns an implementation-dependent value.</p>

                              <div class="method-source-code" id="3E-3D-source">
            <pre>static VALUE
flo_ge(VALUE x, VALUE y)
{
    double a, b;

    a = RFLOAT_VALUE(x);
    if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
        VALUE rel = rb_integer_float_cmp(y, x);
        if (FIXNUM_P(rel))
            return RBOOL(-FIX2LONG(rel) &gt;= 0);
        return Qfalse;
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
        if (isnan(b)) return Qfalse;
#endif
    }
    else {
        return rb_num_coerce_relop(x, y, idGE);
    }
#if MSC_VERSION_BEFORE(1300)
    if (isnan(a)) return Qfalse;
#endif
    return RBOOL(a &gt;= b);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-abs" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          abs &rarr;  float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the absolute value of <code>self</code>:</p>

<pre class="ruby">(<span class="ruby-value">-34.56</span>).<span class="ruby-identifier">abs</span> <span class="ruby-comment"># =&gt; 34.56</span>
<span class="ruby-value">-34.56</span>.<span class="ruby-identifier">abs</span>   <span class="ruby-comment"># =&gt; 34.56</span>
<span class="ruby-value">34.56</span>.<span class="ruby-identifier">abs</span>    <span class="ruby-comment"># =&gt; 34.56</span>
</pre>

                              <div class="method-source-code" id="abs-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/numeric.rb, line 325</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">abs</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;rb_float_abs(self)&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-angle" class="method-detail method-alias">
                      <div class="method-heading">
                        <span class="method-callseq">
                          angle  &rarr;  0 or float
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns 0 if the value is positive, pi otherwise.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Float.html#method-i-arg">arg</a>
                            </div>
                          </div>

                  <div id="method-i-arg" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          arg    &rarr;  0 or float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns 0 if the value is positive, pi otherwise.</p>

                              <div class="method-source-code" id="arg-source">
            <pre>static VALUE
float_arg(VALUE self)
{
    if (isnan(RFLOAT_VALUE(self)))
        return self;
    if (f_tpositive_p(self))
        return INT2FIX(0);
    return rb_const_get(rb_mMath, id_PI);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Float.html#method-i-angle">angle</a>, <a href="Float.html#method-i-phase">phase</a>
                            </div>

                          </div>

                  <div id="method-i-ceil" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ceil(ndigits = 0) &rarr; float or integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the smallest number greater than or equal to <code>self</code> with a precision of <code>ndigits</code> decimal digits.</p>

<p>When <code>ndigits</code> is positive, returns a float with <code>ndigits</code> digits after the decimal point (as available):</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 12345.7</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 12345.679</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; -12345.6</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; -12345.678</span>
</pre>

<p>When <code>ndigits</code> is non-positive, returns an integer with at least <code>ndigits.abs</code> trailing zeros:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; 12346</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; 13000</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; -12345</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">ceil</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; -12000</span>
</pre>

<p>Note that the limited precision of floating-point arithmetic may lead to surprising results:</p>

<pre class="ruby">(<span class="ruby-value">2.1</span> <span class="ruby-operator">/</span> <span class="ruby-value">0.7</span>).<span class="ruby-identifier">ceil</span>  <span class="ruby-comment">#=&gt; 4 (!)</span>
</pre>

<p>Related: <a href="Float.html#method-i-floor"><code>Float#floor</code></a>.</p>

                              <div class="method-source-code" id="ceil-source">
            <pre>static VALUE
flo_ceil(int argc, VALUE *argv, VALUE num)
{
    int ndigits = flo_ndigits(argc, argv);
    return rb_float_ceil(num, ndigits);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-coerce" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          coerce(other) &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a 2-element array containing <code>other</code> converted to a Float and <code>self</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>                 <span class="ruby-comment"># =&gt; 3.14</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-value">2</span>)              <span class="ruby-comment"># =&gt; [2.0, 3.14]</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-value">2.0</span>)            <span class="ruby-comment"># =&gt; [2.0, 3.14]</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-constant">Rational</span>(<span class="ruby-value">1</span>, <span class="ruby-value">2</span>)) <span class="ruby-comment"># =&gt; [0.5, 3.14]</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-constant">Complex</span>(<span class="ruby-value">1</span>, <span class="ruby-value">0</span>))  <span class="ruby-comment"># =&gt; [1.0, 3.14]</span>
</pre>

<p>Raises an exception if a type conversion fails.</p>

                              <div class="method-source-code" id="coerce-source">
            <pre>static VALUE
flo_coerce(VALUE x, VALUE y)
{
    return rb_assoc_new(rb_Float(y), x);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-denominator" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          denominator  &rarr;  integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the denominator (always positive).  The result is machine dependent.</p>

<p>See also <a href="Float.html#method-i-numerator"><code>Float#numerator</code></a>.</p>

                              <div class="method-source-code" id="denominator-source">
            <pre>VALUE
rb_float_denominator(VALUE self)
{
    double d = RFLOAT_VALUE(self);
    VALUE r;
    if (!isfinite(d))
        return INT2FIX(1);
    r = float_to_r(self);
    return nurat_denominator(r);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-divmod" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          divmod(other) &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a 2-element array <code>[q, r]</code>, where</p>

<pre class="ruby"><span class="ruby-identifier">q</span> = (<span class="ruby-keyword">self</span><span class="ruby-operator">/</span><span class="ruby-identifier">other</span>).<span class="ruby-identifier">floor</span>      <span class="ruby-comment"># Quotient</span>
<span class="ruby-identifier">r</span> = <span class="ruby-keyword">self</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">other</span>            <span class="ruby-comment"># Remainder</span>
</pre>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-value">11.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">4</span>)              <span class="ruby-comment"># =&gt; [2, 3.0]</span>
<span class="ruby-value">11.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">-4</span>)             <span class="ruby-comment"># =&gt; [-3, -1.0]</span>
<span class="ruby-value">-11.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">4</span>)             <span class="ruby-comment"># =&gt; [-3, 1.0]</span>
<span class="ruby-value">-11.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">-4</span>)            <span class="ruby-comment"># =&gt; [2, -3.0]</span>

<span class="ruby-value">12.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">4</span>)              <span class="ruby-comment"># =&gt; [3, 0.0]</span>
<span class="ruby-value">12.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">-4</span>)             <span class="ruby-comment"># =&gt; [-3, 0.0]</span>
<span class="ruby-value">-12.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">4</span>)             <span class="ruby-comment"># =&gt; [-3, -0.0]</span>
<span class="ruby-value">-12.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">-4</span>)            <span class="ruby-comment"># =&gt; [3, -0.0]</span>

<span class="ruby-value">13.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-value">4.0</span>)            <span class="ruby-comment"># =&gt; [3, 1.0]</span>
<span class="ruby-value">13.0</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-constant">Rational</span>(<span class="ruby-value">4</span>, <span class="ruby-value">1</span>)) <span class="ruby-comment"># =&gt; [3, 1.0]</span>
</pre>

                              <div class="method-source-code" id="divmod-source">
            <pre>static VALUE
flo_divmod(VALUE x, VALUE y)
{
    double fy, div, mod;
    volatile VALUE a, b;

    if (FIXNUM_P(y)) {
        fy = (double)FIX2LONG(y);
    }
    else if (RB_BIGNUM_TYPE_P(y)) {
        fy = rb_big2dbl(y);
    }
    else if (RB_FLOAT_TYPE_P(y)) {
        fy = RFLOAT_VALUE(y);
    }
    else {
        return rb_num_coerce_bin(x, y, id_divmod);
    }
    flodivmod(RFLOAT_VALUE(x), fy, &amp;div, &amp;mod);
    a = dbl2ival(div);
    b = DBL2NUM(mod);
    return rb_assoc_new(a, b);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-eql-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          eql?(other) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>other</code> is a Float with the same value as <code>self</code>, <code>false</code> otherwise:</p>

<pre class="ruby"><span class="ruby-value">2.0</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-value">2.0</span>)            <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-value">2.0</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-value">1.0</span>)            <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-value">2.0</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-value">1</span>)              <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-value">2.0</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>)) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-value">2.0</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>))  <span class="ruby-comment"># =&gt; false</span>
</pre>

<p><code>Float::NAN.eql?(Float::NAN)</code> returns an implementation-dependent value.</p>

<p>Related: <a href="Float.html#method-i-3D-3D"><code>Float#==</code></a> (performs type conversions).</p>

                              <div class="method-source-code" id="eql-3F-source">
            <pre>VALUE
rb_float_eql(VALUE x, VALUE y)
{
    if (RB_FLOAT_TYPE_P(y)) {
        double a = RFLOAT_VALUE(x);
        double b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
        if (isnan(a) || isnan(b)) return Qfalse;
#endif
    return RBOOL(a == b);
    }
    return Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fdiv" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">fdiv</span><span
                                class="method-args">(p1)</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the quotient from dividing <code>self</code> by <code>other</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-value">2</span>)              <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-value">-2</span>)             <span class="ruby-comment"># =&gt; -1.57</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>)) <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>))  <span class="ruby-comment"># =&gt; (1.57+0.0i)</span>
</pre>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Float.html#method-i-quo">quo</a>
                            </div>
                          </div>

                  <div id="method-i-finite-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          finite? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is not <code>Infinity</code>, <code>-Infinity</code>, or <code>NaN</code>, <code>false</code> otherwise:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">2.0</span>      <span class="ruby-comment"># =&gt; 2.0</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">finite?</span>    <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span>  <span class="ruby-comment"># =&gt; Infinity</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">finite?</span>    <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span> <span class="ruby-comment"># =&gt; -Infinity</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">finite?</span>    <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">0.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span>  <span class="ruby-comment"># =&gt; NaN</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">finite?</span>    <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="finite-3F-source">
            <pre>VALUE
rb_flo_is_finite_p(VALUE num)
{
    double value = RFLOAT_VALUE(num);

    return RBOOL(isfinite(value));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-floor" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          floor(ndigits = 0) &rarr; float or integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the largest number less than or equal to <code>self</code> with a precision of <code>ndigits</code> decimal digits.</p>

<p>When <code>ndigits</code> is positive, returns a float with <code>ndigits</code> digits after the decimal point (as available):</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 12345.6</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 12345.678</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; -12345.7</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; -12345.679</span>
</pre>

<p>When <code>ndigits</code> is non-positive, returns an integer with at least <code>ndigits.abs</code> trailing zeros:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; 12345</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; 12000</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; -12346</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">floor</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; -13000</span>
</pre>

<p>Note that the limited precision of floating-point arithmetic may lead to surprising results:</p>

<pre class="ruby">(<span class="ruby-value">0.3</span> <span class="ruby-operator">/</span> <span class="ruby-value">0.1</span>).<span class="ruby-identifier">floor</span>  <span class="ruby-comment">#=&gt; 2 (!)</span>
</pre>

<p>Related: <a href="Float.html#method-i-ceil"><code>Float#ceil</code></a>.</p>

                              <div class="method-source-code" id="floor-source">
            <pre>static VALUE
flo_floor(int argc, VALUE *argv, VALUE num)
{
    int ndigits = flo_ndigits(argc, argv);
    return rb_float_floor(num, ndigits);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          hash &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the integer hash value for <code>self</code>.</p>

<p>See also <a href="Object.html#method-i-hash"><code>Object#hash</code></a>.</p>

                              <div class="method-source-code" id="hash-source">
            <pre>static VALUE
flo_hash(VALUE num)
{
    return rb_dbl_hash(RFLOAT_VALUE(num));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-infinite-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          infinite? &rarr; -1, 1, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns:</p>
<ul><li>
<p>1, if <code>self</code> is <code>Infinity</code>.</p>
</li><li>
<p>-1 if <code>self</code> is <code>-Infinity</code>.</p>
</li><li>
<p><code>nil</code>, otherwise.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span>  <span class="ruby-comment"># =&gt; Infinity</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">infinite?</span>  <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span> <span class="ruby-comment"># =&gt; -Infinity</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">infinite?</span>  <span class="ruby-comment"># =&gt; -1</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">1.0</span>      <span class="ruby-comment"># =&gt; 1.0</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">infinite?</span>  <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">0.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span>  <span class="ruby-comment"># =&gt; NaN</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">infinite?</span>  <span class="ruby-comment"># =&gt; nil</span>
</pre>

                              <div class="method-source-code" id="infinite-3F-source">
            <pre>VALUE
rb_flo_is_infinite_p(VALUE num)
{
    double value = RFLOAT_VALUE(num);

    if (isinf(value)) {
        return INT2FIX( value &lt; 0 ? -1 : 1 );
    }

    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string containing a representation of <code>self</code>; depending of the value of <code>self</code>, the string representation may contain:</p>
<ul><li>
<p>A fixed-point number.</p>
</li><li>
<p>A number in “scientific notation” (containing an exponent).</p>
</li><li>
<p>‘Infinity’.</p>
</li><li>
<p>‘-Infinity’.</p>
</li><li>
<p>‘NaN’ (indicating not-a-number).</p>

<p>3.14.to_s         # =&gt; “3.14” (10.1**50).to_s   # =&gt; “1.644631821843879e+50” (10.1**500).to_s  # =&gt; “Infinity” (-10.1**500).to_s # =&gt; “-Infinity” (0.0/0.0).to_s    # =&gt; “NaN”</p>
</li></ul>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Float.html#method-i-to_s">to_s</a>
                            </div>
                          </div>

                  <div id="method-i-magnitude" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">magnitude</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="magnitude-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/numeric.rb, line 330</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">magnitude</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;rb_float_abs(self)&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-modulo" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">modulo</span><span
                                class="method-args">(p1)</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code> modulo <code>other</code> as a float.</p>

<p>For float <code>f</code> and real number <code>r</code>, these expressions are equivalent:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">r</span>
<span class="ruby-identifier">f</span><span class="ruby-operator">-</span><span class="ruby-identifier">r</span><span class="ruby-operator">*</span>(<span class="ruby-identifier">f</span><span class="ruby-operator">/</span><span class="ruby-identifier">r</span>).<span class="ruby-identifier">floor</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-identifier">r</span>)[<span class="ruby-value">1</span>]
</pre>

<p>See <a href="Numeric.html#method-i-divmod"><code>Numeric#divmod</code></a>.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">2</span>              <span class="ruby-comment"># =&gt; 0.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">3</span>              <span class="ruby-comment"># =&gt; 1.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">4</span>              <span class="ruby-comment"># =&gt; 2.0</span>

<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">-2</span>             <span class="ruby-comment"># =&gt; 0.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">-3</span>             <span class="ruby-comment"># =&gt; -2.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">-4</span>             <span class="ruby-comment"># =&gt; -2.0</span>

<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-value">4.0</span>            <span class="ruby-comment"># =&gt; 2.0</span>
<span class="ruby-value">10.0</span> <span class="ruby-operator">%</span> <span class="ruby-constant">Rational</span>(<span class="ruby-value">4</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 2.0</span>
</pre>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Float.html#method-i-25">%</a>
                            </div>
                          </div>

                  <div id="method-i-nan-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          nan? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is a NaN, <code>false</code> otherwise.</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">-1.0</span>     <span class="ruby-comment">#=&gt; -1.0</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">nan?</span>       <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">0.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span>  <span class="ruby-comment">#=&gt; NaN</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">nan?</span>       <span class="ruby-comment">#=&gt; true</span>
</pre>

                              <div class="method-source-code" id="nan-3F-source">
            <pre>static VALUE
flo_is_nan_p(VALUE num)
{
    double value = RFLOAT_VALUE(num);

    return RBOOL(isnan(value));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-negative-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          negative? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is less than 0, <code>false</code> otherwise.</p>

                              <div class="method-source-code" id="negative-3F-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/numeric.rb, line 367</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">negative?</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;RBOOL(RFLOAT_VALUE(self) &lt; 0.0)&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-next_float" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          next_float &rarr; float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the next-larger representable Float.</p>

<p>These examples show the internally stored values (64-bit hexadecimal) for each Float <code>f</code> and for the corresponding <code>f.next_float</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">0.0</span>      <span class="ruby-comment"># 0x0000000000000000</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">next_float</span> <span class="ruby-comment"># 0x0000000000000001</span>

<span class="ruby-identifier">f</span> = <span class="ruby-value">0.01</span>     <span class="ruby-comment"># 0x3f847ae147ae147b</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">next_float</span> <span class="ruby-comment"># 0x3f847ae147ae147c</span>
</pre>

<p>In the remaining examples here, the output is shown in the usual way (result <code>to_s</code>):</p>

<pre class="ruby"><span class="ruby-value">0.01</span>.<span class="ruby-identifier">next_float</span>    <span class="ruby-comment"># =&gt; 0.010000000000000002</span>
<span class="ruby-value">1.0</span>.<span class="ruby-identifier">next_float</span>     <span class="ruby-comment"># =&gt; 1.0000000000000002</span>
<span class="ruby-value">100.0</span>.<span class="ruby-identifier">next_float</span>   <span class="ruby-comment"># =&gt; 100.00000000000001</span>

<span class="ruby-identifier">f</span> = <span class="ruby-value">0.01</span>
(<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>).<span class="ruby-identifier">each_with_index</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">printf</span> <span class="ruby-string">&quot;%2d %-20a %s\n&quot;</span>, <span class="ruby-identifier">i</span>, <span class="ruby-identifier">f</span>, <span class="ruby-identifier">f</span>.<span class="ruby-identifier">to_s</span>; <span class="ruby-identifier">f</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">next_float</span> }
</pre>

<p>Output:</p>

<pre> 0 0x1.47ae147ae147bp-7 0.01
 1 0x1.47ae147ae147cp-7 0.010000000000000002
 2 0x1.47ae147ae147dp-7 0.010000000000000004
 3 0x1.47ae147ae147ep-7 0.010000000000000005

f = 0.0; 100.times { f += 0.1 }
f                           # =&gt; 9.99999999999998       # should be 10.0 in the ideal world.
10-f                        # =&gt; 1.9539925233402755e-14 # the floating point error.
10.0.next_float-10          # =&gt; 1.7763568394002505e-15 # 1 ulp (unit in the last place).
(10-f)/(10.0.next_float-10) # =&gt; 11.0                   # the error is 11 ulp.
(10-f)/(10*Float::EPSILON)  # =&gt; 8.8                    # approximation of the above.
&quot;%a&quot; % 10                   # =&gt; &quot;0x1.4p+3&quot;
&quot;%a&quot; % f                    # =&gt; &quot;0x1.3fffffffffff5p+3&quot; # the last hex digit is 5.  16 - 5 = 11 ulp.</pre>

<p>Related: <a href="Float.html#method-i-prev_float"><code>Float#prev_float</code></a></p>

                              <div class="method-source-code" id="next_float-source">
            <pre>static VALUE
flo_next_float(VALUE vx)
{
    return flo_nextafter(vx, HUGE_VAL);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-numerator" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          numerator  &rarr;  integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the numerator.  The result is machine dependent.</p>

<pre class="ruby"><span class="ruby-identifier">n</span> = <span class="ruby-value">0.3</span>.<span class="ruby-identifier">numerator</span>    <span class="ruby-comment">#=&gt; 5404319552844595</span>
<span class="ruby-identifier">d</span> = <span class="ruby-value">0.3</span>.<span class="ruby-identifier">denominator</span>  <span class="ruby-comment">#=&gt; 18014398509481984</span>
<span class="ruby-identifier">n</span>.<span class="ruby-identifier">fdiv</span>(<span class="ruby-identifier">d</span>)            <span class="ruby-comment">#=&gt; 0.3</span>
</pre>

<p>See also <a href="Float.html#method-i-denominator"><code>Float#denominator</code></a>.</p>

                              <div class="method-source-code" id="numerator-source">
            <pre>VALUE
rb_float_numerator(VALUE self)
{
    double d = RFLOAT_VALUE(self);
    VALUE r;
    if (!isfinite(d))
        return self;
    r = float_to_r(self);
    return nurat_numerator(r);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-phase" class="method-detail method-alias">
                      <div class="method-heading">
                        <span class="method-callseq">
                          phase  &rarr;  0 or float
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns 0 if the value is positive, pi otherwise.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Float.html#method-i-arg">arg</a>
                            </div>
                          </div>

                  <div id="method-i-positive-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          positive? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is greater than 0, <code>false</code> otherwise.</p>

                              <div class="method-source-code" id="positive-3F-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/numeric.rb, line 358</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">positive?</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;RBOOL(RFLOAT_VALUE(self) &gt; 0.0)&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prev_float" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          prev_float  &rarr;  float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the next-smaller representable Float.</p>

<p>These examples show the internally stored values (64-bit hexadecimal) for each Float <code>f</code> and for the corresponding <code>f.pev_float</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">5e-324</span>   <span class="ruby-comment"># 0x0000000000000001</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">prev_float</span> <span class="ruby-comment"># 0x0000000000000000</span>

<span class="ruby-identifier">f</span> = <span class="ruby-value">0.01</span>     <span class="ruby-comment"># 0x3f847ae147ae147b</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">prev_float</span> <span class="ruby-comment"># 0x3f847ae147ae147a</span>
</pre>

<p>In the remaining examples here, the output is shown in the usual way (result <code>to_s</code>):</p>

<pre class="ruby"><span class="ruby-value">0.01</span>.<span class="ruby-identifier">prev_float</span>   <span class="ruby-comment"># =&gt; 0.009999999999999998</span>
<span class="ruby-value">1.0</span>.<span class="ruby-identifier">prev_float</span>    <span class="ruby-comment"># =&gt; 0.9999999999999999</span>
<span class="ruby-value">100.0</span>.<span class="ruby-identifier">prev_float</span>  <span class="ruby-comment"># =&gt; 99.99999999999999</span>

<span class="ruby-identifier">f</span> = <span class="ruby-value">0.01</span>
(<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>).<span class="ruby-identifier">each_with_index</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">printf</span> <span class="ruby-string">&quot;%2d %-20a %s\n&quot;</span>, <span class="ruby-identifier">i</span>, <span class="ruby-identifier">f</span>, <span class="ruby-identifier">f</span>.<span class="ruby-identifier">to_s</span>; <span class="ruby-identifier">f</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">prev_float</span> }
</pre>

<p>Output:</p>

<pre>0 0x1.47ae147ae147bp-7 0.01
1 0x1.47ae147ae147ap-7 0.009999999999999998
2 0x1.47ae147ae1479p-7 0.009999999999999997
3 0x1.47ae147ae1478p-7 0.009999999999999995</pre>

<p>Related: <a href="Float.html#method-i-next_float"><code>Float#next_float</code></a>.</p>

                              <div class="method-source-code" id="prev_float-source">
            <pre>static VALUE
flo_prev_float(VALUE vx)
{
    return flo_nextafter(vx, -HUGE_VAL);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-quo" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          quo(other) &rarr; numeric
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the quotient from dividing <code>self</code> by <code>other</code>:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">3.14</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-value">2</span>)              <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-value">-2</span>)             <span class="ruby-comment"># =&gt; -1.57</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-constant">Rational</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>)) <span class="ruby-comment"># =&gt; 1.57</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">quo</span>(<span class="ruby-constant">Complex</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>))  <span class="ruby-comment"># =&gt; (1.57+0.0i)</span>
</pre>

                              <div class="method-source-code" id="quo-source">
            <pre>static VALUE
flo_quo(VALUE x, VALUE y)
{
    return num_funcall1(x, &#39;/&#39;, y);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Float.html#method-i-fdiv">fdiv</a>
                            </div>

                          </div>

                  <div id="method-i-rationalize" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          rationalize([eps])  &rarr;  rational
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a simpler approximation of the value (flt-|eps| &lt;= result &lt;= flt+|eps|).  If the optional argument <code>eps</code> is not given, it will be chosen automatically.</p>

<pre class="ruby"><span class="ruby-value">0.3</span>.<span class="ruby-identifier">rationalize</span>          <span class="ruby-comment">#=&gt; (3/10)</span>
<span class="ruby-value">1.333</span>.<span class="ruby-identifier">rationalize</span>        <span class="ruby-comment">#=&gt; (1333/1000)</span>
<span class="ruby-value">1.333</span>.<span class="ruby-identifier">rationalize</span>(<span class="ruby-value">0.01</span>)  <span class="ruby-comment">#=&gt; (4/3)</span>
</pre>

<p>See also <a href="Float.html#method-i-to_r"><code>Float#to_r</code></a>.</p>

                              <div class="method-source-code" id="rationalize-source">
            <pre>static VALUE
float_rationalize(int argc, VALUE *argv, VALUE self)
{
    double d = RFLOAT_VALUE(self);
    VALUE rat;
    int neg = d &lt; 0.0;
    if (neg) self = DBL2NUM(-d);

    if (rb_check_arity(argc, 0, 1)) {
        rat = rb_flt_rationalize_with_prec(self, argv[0]);
    }
    else {
        rat = rb_flt_rationalize(self);
    }
    if (neg) RATIONAL_SET_NUM(rat, rb_int_uminus(RRATIONAL(rat)-&gt;num));
    return rat;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-round" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          round(ndigits = 0, half: :up]) &rarr; integer or float
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code> rounded to the nearest value with a precision of <code>ndigits</code> decimal digits.</p>

<p>When <code>ndigits</code> is non-negative, returns a float with <code>ndigits</code> after the decimal point (as available):</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 12345.7</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 12345.679</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; -12345.7</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; -12345.679</span>
</pre>

<p>When <code>ndigits</code> is negative, returns an integer with at least <code>ndigits.abs</code> trailing zeros:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; 12346</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; 12000</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; -12346</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; -12000</span>
</pre>

<p>If keyword argument <code>half</code> is given, and <code>self</code> is equidistant from the two candidate values, the rounding is according to the given <code>half</code> value:</p>
<ul><li>
<p><code>:up</code> or <code>nil</code>: round away from zero:</p>

<pre class="ruby"><span class="ruby-value">2.5</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:up</span>)      <span class="ruby-comment"># =&gt; 3</span>
<span class="ruby-value">3.5</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:up</span>)      <span class="ruby-comment"># =&gt; 4</span>
(<span class="ruby-value">-2.5</span>).<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:up</span>)   <span class="ruby-comment"># =&gt; -3</span>
</pre>
</li><li>
<p><code>:down</code>: round toward zero:</p>

<pre class="ruby"><span class="ruby-value">2.5</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:down</span>)    <span class="ruby-comment"># =&gt; 2</span>
<span class="ruby-value">3.5</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:down</span>)    <span class="ruby-comment"># =&gt; 3</span>
(<span class="ruby-value">-2.5</span>).<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:down</span>) <span class="ruby-comment"># =&gt; -2</span>
</pre>
</li><li>
<p><code>:even</code>: round toward the candidate whose last nonzero digit is even:</p>

<pre class="ruby"><span class="ruby-value">2.5</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:even</span>)    <span class="ruby-comment"># =&gt; 2</span>
<span class="ruby-value">3.5</span>.<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:even</span>)    <span class="ruby-comment"># =&gt; 4</span>
(<span class="ruby-value">-2.5</span>).<span class="ruby-identifier">round</span>(<span class="ruby-value">half:</span> <span class="ruby-value">:even</span>) <span class="ruby-comment"># =&gt; -2</span>
</pre>
</li></ul>

<p>Raises and exception if the value for <code>half</code> is invalid.</p>

<p>Related: <a href="Float.html#method-i-truncate"><code>Float#truncate</code></a>.</p>

                              <div class="method-source-code" id="round-source">
            <pre>static VALUE
flo_round(int argc, VALUE *argv, VALUE num)
{
    double number, f, x;
    VALUE nd, opt;
    int ndigits = 0;
    enum ruby_num_rounding_mode mode;

    if (rb_scan_args(argc, argv, &quot;01:&quot;, &amp;nd, &amp;opt)) {
        ndigits = NUM2INT(nd);
    }
    mode = rb_num_get_rounding_option(opt);
    number = RFLOAT_VALUE(num);
    if (number == 0.0) {
        return ndigits &gt; 0 ? DBL2NUM(number) : INT2FIX(0);
    }
    if (ndigits &lt; 0) {
        return rb_int_round(flo_to_i(num), ndigits, mode);
    }
    if (ndigits == 0) {
        x = ROUND_CALL(mode, round, (number, 1.0));
        return dbl2ival(x);
    }
    if (isfinite(number)) {
        int binexp;
        frexp(number, &amp;binexp);
        if (float_round_overflow(ndigits, binexp)) return num;
        if (float_round_underflow(ndigits, binexp)) return DBL2NUM(0);
        if (ndigits &gt; 14) {
            /* In this case, pow(10, ndigits) may not be accurate. */
            return rb_flo_round_by_rational(argc, argv, num);
        }
        f = pow(10, ndigits);
        x = ROUND_CALL(mode, round, (number, f));
        return DBL2NUM(x / f);
    }
    return num;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_f" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_f &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code> (which is already a Float).</p>

                              <div class="method-source-code" id="to_f-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/numeric.rb, line 312</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_f</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_i" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_i &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code> truncated to an <a href="Integer.html"><code>Integer</code></a>.</p>

<pre class="ruby"><span class="ruby-value">1.2</span>.<span class="ruby-identifier">to_i</span>    <span class="ruby-comment"># =&gt; 1</span>
(<span class="ruby-value">-1.2</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-comment"># =&gt; -1</span>
</pre>

<p>Note that the limited precision of floating-point arithmetic may lead to surprising results:</p>

<pre class="ruby">(<span class="ruby-value">0.3</span> <span class="ruby-operator">/</span> <span class="ruby-value">0.1</span>).<span class="ruby-identifier">to_i</span>  <span class="ruby-comment"># =&gt; 2 (!)</span>
</pre>

                              <div class="method-source-code" id="to_i-source">
            <pre>static VALUE
flo_to_i(VALUE num)
{
    double f = RFLOAT_VALUE(num);

    if (f &gt; 0.0) f = floor(f);
    if (f &lt; 0.0) f = ceil(f);

    return dbl2ival(f);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Float.html#method-i-to_int">to_int</a>
                            </div>

                          </div>

                  <div id="method-i-to_int" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">to_int</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code> truncated to an <a href="Integer.html"><code>Integer</code></a>.</p>

<pre class="ruby"><span class="ruby-value">1.2</span>.<span class="ruby-identifier">to_i</span>    <span class="ruby-comment"># =&gt; 1</span>
(<span class="ruby-value">-1.2</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-comment"># =&gt; -1</span>
</pre>

<p>Note that the limited precision of floating-point arithmetic may lead to surprising results:</p>

<pre class="ruby">(<span class="ruby-value">0.3</span> <span class="ruby-operator">/</span> <span class="ruby-value">0.1</span>).<span class="ruby-identifier">to_i</span>  <span class="ruby-comment"># =&gt; 2 (!)</span>
</pre>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Float.html#method-i-to_i">to_i</a>
                            </div>
                          </div>

                  <div id="method-i-to_r" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_r  &rarr;  rational
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the value as a rational.</p>

<pre class="ruby"><span class="ruby-value">2.0</span>.<span class="ruby-identifier">to_r</span>    <span class="ruby-comment">#=&gt; (2/1)</span>
<span class="ruby-value">2.5</span>.<span class="ruby-identifier">to_r</span>    <span class="ruby-comment">#=&gt; (5/2)</span>
<span class="ruby-value">-0.75</span>.<span class="ruby-identifier">to_r</span>  <span class="ruby-comment">#=&gt; (-3/4)</span>
<span class="ruby-value">0.0</span>.<span class="ruby-identifier">to_r</span>    <span class="ruby-comment">#=&gt; (0/1)</span>
<span class="ruby-value">0.3</span>.<span class="ruby-identifier">to_r</span>    <span class="ruby-comment">#=&gt; (5404319552844595/18014398509481984)</span>
</pre>

<p>NOTE: 0.3.to_r isn’t the same as “0.3”.to_r.  The latter is equivalent to “3/10”.to_r, but the former isn’t so.</p>

<pre class="ruby"><span class="ruby-value">0.3</span>.<span class="ruby-identifier">to_r</span>   <span class="ruby-operator">==</span> <span class="ruby-value">3</span><span class="ruby-operator">/</span><span class="ruby-value">10r</span>  <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-string">&quot;0.3&quot;</span>.<span class="ruby-identifier">to_r</span> <span class="ruby-operator">==</span> <span class="ruby-value">3</span><span class="ruby-operator">/</span><span class="ruby-value">10r</span>  <span class="ruby-comment">#=&gt; true</span>
</pre>

<p>See also <a href="Float.html#method-i-rationalize"><code>Float#rationalize</code></a>.</p>

                              <div class="method-source-code" id="to_r-source">
            <pre>static VALUE
float_to_r(VALUE self)
{
    VALUE f;
    int n;

    float_decode_internal(self, &amp;f, &amp;n);
#if FLT_RADIX == 2
    if (n == 0)
        return rb_rational_new1(f);
    if (n &gt; 0)
        return rb_rational_new1(rb_int_lshift(f, INT2FIX(n)));
    n = -n;
    return rb_rational_new2(f, rb_int_lshift(ONE, INT2FIX(n)));
#else
    f = rb_int_mul(f, rb_int_pow(INT2FIX(FLT_RADIX), n));
    if (RB_TYPE_P(f, T_RATIONAL))
        return f;
    return rb_rational_new1(f);
#endif
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string containing a representation of <code>self</code>; depending of the value of <code>self</code>, the string representation may contain:</p>
<ul><li>
<p>A fixed-point number.</p>
</li><li>
<p>A number in “scientific notation” (containing an exponent).</p>
</li><li>
<p>‘Infinity’.</p>
</li><li>
<p>‘-Infinity’.</p>
</li><li>
<p>‘NaN’ (indicating not-a-number).</p>

<p>3.14.to_s         # =&gt; “3.14” (10.1**50).to_s   # =&gt; “1.644631821843879e+50” (10.1**500).to_s  # =&gt; “Infinity” (-10.1**500).to_s # =&gt; “-Infinity” (0.0/0.0).to_s    # =&gt; “NaN”</p>
</li></ul>

                              <div class="method-source-code" id="to_s-source">
            <pre>static VALUE
flo_to_s(VALUE flt)
{
    enum {decimal_mant = DBL_MANT_DIG-DBL_DIG};
    enum {float_dig = DBL_DIG+1};
    char buf[float_dig + roomof(decimal_mant, CHAR_BIT) + 10];
    double value = RFLOAT_VALUE(flt);
    VALUE s;
    char *p, *e;
    int sign, decpt, digs;

    if (isinf(value)) {
        static const char minf[] = &quot;-Infinity&quot;;
        const int pos = (value &gt; 0); /* skip &quot;-&quot; */
        return rb_usascii_str_new(minf+pos, strlen(minf)-pos);
    }
    else if (isnan(value))
        return rb_usascii_str_new2(&quot;NaN&quot;);

    p = ruby_dtoa(value, 0, 0, &amp;decpt, &amp;sign, &amp;e);
    s = sign ? rb_usascii_str_new_cstr(&quot;-&quot;) : rb_usascii_str_new(0, 0);
    if ((digs = (int)(e - p)) &gt;= (int)sizeof(buf)) digs = (int)sizeof(buf) - 1;
    memcpy(buf, p, digs);
    xfree(p);
    if (decpt &gt; 0) {
        if (decpt &lt; digs) {
            memmove(buf + decpt + 1, buf + decpt, digs - decpt);
            buf[decpt] = &#39;.&#39;;
            rb_str_cat(s, buf, digs + 1);
        }
        else if (decpt &lt;= DBL_DIG) {
            long len;
            char *ptr;
            rb_str_cat(s, buf, digs);
            rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs + 2);
            ptr = RSTRING_PTR(s) + len;
            if (decpt &gt; digs) {
                memset(ptr, &#39;0&#39;, decpt - digs);
                ptr += decpt - digs;
            }
            memcpy(ptr, &quot;.0&quot;, 2);
        }
        else {
            goto exp;
        }
    }
    else if (decpt &gt; -4) {
        long len;
        char *ptr;
        rb_str_cat(s, &quot;0.&quot;, 2);
        rb_str_resize(s, (len = RSTRING_LEN(s)) - decpt + digs);
        ptr = RSTRING_PTR(s);
        memset(ptr += len, &#39;0&#39;, -decpt);
        memcpy(ptr -= decpt, buf, digs);
    }
    else {
        goto exp;
    }
    return s;

  exp:
    if (digs &gt; 1) {
        memmove(buf + 2, buf + 1, digs - 1);
    }
    else {
        buf[2] = &#39;0&#39;;
        digs++;
    }
    buf[1] = &#39;.&#39;;
    rb_str_cat(s, buf, digs + 1);
    rb_str_catf(s, &quot;e%+03d&quot;, decpt - 1);
    return s;
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Float.html#method-i-inspect">inspect</a>
                            </div>

                          </div>

                  <div id="method-i-truncate" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          truncate(ndigits = 0) &rarr; float or integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>self</code> truncated (toward zero) to a precision of <code>ndigits</code> decimal digits.</p>

<p>When <code>ndigits</code> is positive, returns a float with <code>ndigits</code> digits after the decimal point (as available):</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 12345.6</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; 12345.678</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; -12345.6</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; -12345.678</span>
</pre>

<p>When <code>ndigits</code> is negative, returns an integer with at least <code>ndigits.abs</code> trailing zeros:</p>

<pre class="ruby"><span class="ruby-identifier">f</span> = <span class="ruby-value">12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; 12345</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; 12000</span>
<span class="ruby-identifier">f</span> = <span class="ruby-value">-12345.6789</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">0</span>)  <span class="ruby-comment"># =&gt; -12345</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; -12000</span>
</pre>

<p>Note that the limited precision of floating-point arithmetic may lead to surprising results:</p>

<pre class="ruby">(<span class="ruby-value">0.3</span> <span class="ruby-operator">/</span> <span class="ruby-value">0.1</span>).<span class="ruby-identifier">truncate</span>  <span class="ruby-comment">#=&gt; 2 (!)</span>
</pre>

<p>Related: <a href="Float.html#method-i-round"><code>Float#round</code></a>.</p>

                              <div class="method-source-code" id="truncate-source">
            <pre>static VALUE
flo_truncate(int argc, VALUE *argv, VALUE num)
{
    if (signbit(RFLOAT_VALUE(num)))
        return flo_ceil(argc, argv, num);
    else
        return flo_floor(argc, argv, num);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-zero-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          zero? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <code>self</code> is 0.0, <code>false</code> otherwise.</p>

                              <div class="method-source-code" id="zero-3F-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/numeric.rb, line 349</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">zero?</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">attr!</span> <span class="ruby-value">:leaf</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">cexpr!</span> <span class="ruby-string">&#39;RBOOL(FLOAT_ZERO_P(self))&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

